import pytest
import requests

test_data = [
    ['admin', 'macro123', '操作成功'],
    ['admin1', 'macro123', '用户名或密码错误'],
    ['admin', 'macro', '密码不正确']
]


class TestLogin:
    @pytest.mark.parametrize('username,password,message', test_data)
    def test_login(self, username, password, message):
        json = {
            'username': username,
            'password': password
        }
        url = "http://47.108.206.100:8080/admin/login"
        resp = requests.post(url, json=json)
        assert resp.status_code == 200
        assert resp.json().get('message') in message


if __name__ == '__main__':
    pytest.main()
